package Server;

import java.io.*;
import java.net.*;

import util.*;

// Define the thread class for handling a new connection
class HandleAClient extends Thread
{
	private Socket connectToClient; // A connected socket
	private Model mym;
	private Logger log;
	
	// Construct a thread
	public HandleAClient(Socket socket, Model m, Logger log)
	{
		this.mym = m;
		this.log = log;
		connectToClient = socket;
	}


	// Implement the run() method for the thread
	public void run()
	{
		try
		{
			// MillParks being send.
			ObjectOutputStream serverOutputStreamMP = new ObjectOutputStream(connectToClient.getOutputStream());
			serverOutputStreamMP.writeObject(mym.get_MillParks());
			//serverOutputStreamMP.close();	
			
			// MillLogs being send.
			ObjectOutputStream serverOutputStreamML = new ObjectOutputStream(connectToClient.getOutputStream());		
			serverOutputStreamML.writeObject(log.getMillLogs());
			//serverOutputStreamML.close();	
		}

		catch(IOException ex)
		{
			System.err.println(ex);
		}
	}
}